const axios = require("axios").default;
exports.fetchVideo = async url => {
  // 解析视频编号
  const file_code = url.split("fs/")[1];

  const [uid, fid] = file_code.split("-") || ["", ""];

  console.log("file_chk", uid, fid);
  // 解析视频file_chk
  const {
    data: { file_chk }
  } = await axios.get(
    `https://webapi.400gb.com/getfile.php?f=${file_code}&passcode=&ref=`,
    { headers: { Origin: "https://545c.com" } }
  );
  console.log("file_chk", file_chk);
  // 获取视频地址API
  const video_url = `https://webapi.400gb.com/get_file_url.php?uid=${uid}&fid=${fid}&file_chk=${file_chk}`;
  console.log("video_url", video_url);
  const {
    data: { downurl }
  } = await axios.get(video_url);
  return downurl;
};
